<!--
* description: 数字输入框通用组件
* author: luojx
* createdDate: 2019-08-29
-->
<template>
  <el-col :span="span">
    <lableName
      :validrule="validrule"
      :cur-label-name="curLabelName"
      :is-show-label="isShowLabel"
      :is-require="isRequire"
      :maxWordCount="dataToObject==null ? 6 :dataToObject.maxWordCount"
    />
    <el-input
      v-model="modelCode"
      :placeholder="placeholder"
      :disabled="disabled"
      :min="dataToObject==null ?null:dataToObject.min"
      :is-type="dataToObject==null ?false :dataToObject.isType"
      :max="dataToObject==null ? null :dataToObject.max"
      @input="input"
      :readonly="readonly"
      size="small"
      :suffix-icon="suffixIcon"
      :clearable="clearable"
      :type="inputType"
      :step="curStep"
      @clear="clearCode"
      @change="sendCode"
    />
    <validateFormate :cur-label-name="curLabelName" :validrule="validrule" />
  </el-col>
</template>
<script>
import { numberInputMixins } from "@/components/wms/mixins/numberInputMixins";
export default {
  components: {
    lableName: () => import("@/components/lableName"), // 标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate") // 校验提示样式组件
  },
  mixins: [numberInputMixins],
  props: {
    placeholder: {
      type: String,
      default: "请输入"
    },
    isInteger: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    input(code) {
      if (this.isInteger) {
        this.modelCode = this.modelCode.replace(/[^\.\d]/g, "");
        this.modelCode = this.modelCode.replace(".", "");
      }
      if (this.isNumInput) {
        this.$emit("numInput", code, this.codeField);
      }
    }
  }
};
</script>
